package cn.com.duiba.millionaire.center.biz.dao.impl;

import cn.com.duiba.millionaire.center.biz.constants.DatabaseSchema;
import cn.com.duiba.millionaire.center.biz.dao.BaseDao;
import cn.com.duiba.millionaire.center.biz.dao.MillionaireMainMeetingDao;
import cn.com.duiba.millionaire.center.biz.entity.MillionaireMainMeetingEntity;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by sty on 1/18/18.
 */
@Repository
public class MillionaireMainMeetingDaoImpl extends BaseDao implements MillionaireMainMeetingDao {
    @Override
    public MillionaireMainMeetingEntity insert(MillionaireMainMeetingEntity millionaireMainMeetingEntity) {
        insert("insert", millionaireMainMeetingEntity);
        return millionaireMainMeetingEntity;
    }

    @Override
    public int updateById(MillionaireMainMeetingEntity millionaireMainMeetingEntity) {
        return update("updateById", millionaireMainMeetingEntity);
    }

    @Override
    public MillionaireMainMeetingEntity findById(Long id) {
        return selectOne("selectById", id);
    }

    @Override
    public Integer findByPageCount() {
        Map<String, Object> params = Maps.newHashMap();
        return selectOne("findByPageCount",params);
    }

    @Override
    public List<MillionaireMainMeetingEntity> findByPage(Integer pageNum, Integer pageSize) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("startIndex", (pageNum - 1) * pageSize);
        params.put("pageSize", pageSize);
        return selectList("findByPage",params);
    }

    @Override
    public int deleteById(Long id) {
        return update("deleteById", id);
    }

    @Override
    public List<MillionaireMainMeetingEntity> findByIds(List<Long> ids) {
        return selectList("findByIds",ids);
    }


    @Override
    protected DatabaseSchema chooseSchema() {
        return DatabaseSchema.MILLIONAIRE_CONFIG;
    }
}
